import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  // Load environment variables
  const env = loadEnv(mode, process.cwd());
  
  
  return {
    plugins: [vue()],
    server: {
      // 开发环境服务器配置
      proxy: {
        // 配置代理，将/api路径代理到目标服务器
        "/api": {
          target: "http://192.168.100.43:10086/api", // 目标服务器地址
          changeOrigin: true, // 允许跨域
          rewrite: (path) => path.replace(/^\/api/, ""), // 重写路径
        },
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "~/styles/element/index.scss" as *;`,
        },
      },
    },
  };
  
});
